home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / misc / makemsgs.zip / MAKEMSGS.BAS < prev    next >
BASIC Source File  |  1994-12-26  |  6KB  |  182 lines

  1. '
  2. ' Copyright (c) 1994, John David Rohner.  All rights reserved.
  3. '
  4. ' THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
  5. ' WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  6. ' MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  7. ' See the documentation for additional information.
  8. '
  9. '
  10. ' $INCLUDE: 'JDRBBS.INC'
  11. '
  12.  
  13. CLEAR,,4096                                    'Stack size (see FRE(-2)).
  14.  
  15.   '
  16.   ' What to give to all areas as default.
  17.   '
  18.   MsgArea.PostSL = 0
  19.   MsgArea.ReadSL = 0
  20.   MsgArea.ScanSL = 0
  21.   MsgArea.StartTime = 0
  22.   MsgArea.EndTime = 0
  23.   MsgArea.BufferSize = 0
  24.   MsgArea.NextNumber = 1
  25.   MsgArea.SubType = 0
  26.   CALL BitSet(MsgArea.SubType,3)          'Net area.
  27.   CALL BitSet(MsgArea.SubType,9)          'EchoMail area.
  28.   MsgArea.MsgOp = "SYSTEM OPERATOR"       'File Manip's or kill PATHS.DAT can
  29.                                           'be used to easy change Msg-Op's.
  30.  
  31.   REDIM Chars$(255)
  32.   FOR K = 0 TO 255
  33.     Chars$(K) = CHR$(K)
  34.   NEXT
  35.   C1310$ = Chars$(13) + Chars$(10)
  36.   Null$ = ""
  37.   K$ = UCASE$(RTRIM$(LTRIM$(Command$)))
  38.   K7 = (RIGHT$(K$,5) = "/TAGS")
  39.   IF K7 THEN K$ = RTRIM$(LEFT$(K$,LEN(K$) - 5))
  40.   K = FindF(K$,FFile)
  41.   IF K = 0 _
  42.      THEN CALL Ansi("1File not found.  Use MakeMsgs <pathname> [/tags]" + C1310$ + C1310$) : _
  43.           END
  44.   K0$ = Chars$(65 + DrCurrent) + ":\"
  45.  
  46.   '
  47.   ' Add the new areas to Message Area definitions.
  48.   '
  49.   CALL Ansi("Adding areas...")
  50.   K = FileOpen(K$,128 + 64 + 2)
  51.   K0 = FileOpen(K0$ + "BBS\GLOBAL\SYSTEM\MSGBASES.DAT",128 + 64 + 2)
  52.   K2 = FileOpen(K0$ + "BBS\GLOBAL\SYSTEM\ECHOS.DAT",128 + 64 + 2)
  53.   K9 = FileLof&(K0,108)
  54.   K8 = K9
  55.   K& = 0
  56.   DO
  57.     MsgArea.Title = FileGetLine$(K,K&)
  58.     IF RTRIM$(MsgArea.Title) <> Null$ _
  59.        THEN K9 = K9 + 1 : _
  60.             CALL FilePutRec(K0,K9,108,MsgArea) : _
  61.             K1 = FileOpen(K0$ + "BBS\GLOBAL\INDEXES\MSGS_" + _
  62.                           RIGHT$(STR$(1000 + K9),3) + ".IDX",128 + 64 + 2) : _
  63.             CALL FileClose(K1) : _
  64.             IF K7 THEN CALL FilePutSEnd(K2,MKI$(K9) + LEFT$(MsgArea.Title,30))
  65.   LOOP UNTIL K& = -1
  66.   CALL FileClose(K2)
  67.   CALL FileClose(K0)
  68.   CALL FileClose(K)
  69.  
  70.   '
  71.   ' Add Last-Read and Messages Waiting fields for the new Message Areas.
  72.   '
  73.   K5 = FileOpen(K0$ + "BBS\GLOBAL\SYSTEM\USERMSGS",128 + 64 + 2)
  74.   K6 = FileOpen("TEMPFILE.TMP",128 + 64 + 2)
  75.   UserMsgInfo$ = STRING$(K8 * 5,0)
  76.  
  77.   K9 = K9 - K8
  78.   CALL Ansi("Updating user Last-Read's for" + STR$(K9) + " areas...")
  79.   K2$ = UserMsgInfo$
  80.   K2 = LEN(UserMsgInfo$)
  81.   K& = FileLof&(K5,1)
  82.   K0& = - K2
  83.   FOR K3 = 0 TO FileLof&(K5,K2) - 1
  84.     K0& = K0& + K2
  85.     CALL FileGetSLoc(K5,K0&,K2$)
  86.     K3$ = LEFT$(K2$,K8 * 4) + STRING$(K9 * 4,0) + _
  87.           MID$(K2$,K8 * 4 + 1) + STRING$(K9,0)
  88.     CALL FilePutSEnd(K6,K3$)
  89.   NEXT
  90.  
  91. 'for when put into jdrbbs.exe
  92. '  UserMsgInfo$ = K3$
  93. '  CALL FileGetSLoc(K6,1& * (BiSearch(5,0,User.UserName) - 1) * LEN(K3$),UserMsgInfo$)
  94.  
  95.   CALL FileClose(K6)
  96.   CALL FileClose(K5)
  97.   CALL KillFile(K0$ + "BBS\GLOBAL\SYSTEM\USERMSGS")
  98.   NAME "TEMPFILE.TMP" AS K0$ + "BBS\GLOBAL\SYSTEM\USERMSGS"
  99.   CALL Ansi("Done." + C1310$)
  100.  
  101. END
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.         '* * * * * *
  109.         ' This routine retrieves the next line of 'sequential' text
  110.         ' from an already opened file.
  111.         '
  112.         ' p   file handle to read from.
  113.         '     If < 0 then we use a 512 buffer instead of a 128 byte
  114.         '     buffer.  (512 is the maximum BLKS file line allowed).
  115.         '
  116.         ' p&  location to start reading from.  p& is increased by the
  117.         '     size of the returned string + 2.  -1 is returned at EOF.
  118.         '
  119.         ' If the retrieved 128 byte buffer has no CR/LF, then returns
  120.         ' with all 128 bytes read.
  121.         '
  122.         ' A line with only a CR/LF on it is returned as a null.
  123.         '
  124.         ' The CR/LF is not included in the returned text.
  125.         '
  126.         ' At EOF, returned text may or may not contain text, but p&
  127.         ' will be -1.
  128.         '
  129.         ' The last line read may or may not contain data (assume it
  130.         ' does).
  131.         '
  132.         ' If ever looking to improve this routine, the following tests
  133.         ' must be done: blank line handling, no CR on line handling, and
  134.         ' only CR on line (or LF).
  135.         '
  136.         ' Date last checked for perfection: Sep 10 1992
  137.         '
  138. FUNCTION FileGetLine$ (p,p&)
  139.  
  140.   IF p > 0 THEN K0 = 128 _
  141.            ELSE p = - p : _
  142.                 K0 = 512
  143.   k& = FileLof&(p,1) - 2
  144.   IF p& >= K& OR p& < 0 THEN FileGetLine$ = Null$ : _
  145.                              p& = -1 : _
  146.                              EXIT FUNCTION
  147.   K$ = SPACE$(K0)
  148.   k = 1
  149.   DO
  150.     IF k = 0 THEN K$ = K$ + K$    'we stop before it gets to 8192.
  151.     CALL FileGetSLoc(p,p&,k$)
  152.     k = StrSrch1(k$,13)
  153.     WHILE K > 0 AND AscMid(K$,k + 1) <> 10
  154.       K = StrSrch2(K,K$,13)
  155.     WEND
  156.     IF K = 0 AND p& + LEN(K$) > K& THEN K = StrSrch1(K$,0)
  157.   LOOP UNTIL k <> 0 OR LEN(K$) >= 4096 OR p& + LEN(K$) > K&
  158.   IF k > 0 THEN k$ = LEFT$(k$,k - 1) _
  159.            ELSE k = LEN(K$)
  160.   p& = p& + k + 1
  161.   IF p& >= k& THEN p& = -1
  162.   FileGetLine$ = k$
  163.  
  164. END FUNCTION
  165.         '
  166.         '* * * *
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173. '
  174. ' to compile: BC MAKEMSGS.BAS /O/S/FS/G2;
  175. ' to link   : LINK /EXEPACK /PACKCODE MAKEMSGS,,,ASSEMBLY\JDRBBS,,
  176. ' requires  : BC.EXE, LINK.EXE, BCL70EFR.LIB, BRT70EFR.LIB, and JDRBBS.LIB
  177. '             (Basic PDS 7.0+, and Juggernaut's assembly library)
  178. '
  179.  
  180.  
  181.  
  182.